<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">        
    <body>

        <ui:composition template="./../../../WEB-INF/templates/noFooterCompanyTemplate.xhtml">

            <ui:define name="content">
                <h:form id="facesForm">
                    <!--<h:outputScript library="javascript" name="jquery.scrollTo-1.4.3.1-min.js"></h:outputScript>!-->
                    <h:outputScript library="javascript" name="waitImages.js"></h:outputScript>
                    <h:outputScript library="javascript" name="viewSearch.js"></h:outputScript>
                    <p:remoteCommand name="addEvents" onstart="iniciarPaginaViewSearch();" autoRun="true" > </p:remoteCommand>
                    <p:ajaxStatus style="width:64px;height:64px;position:fixed;right:55%;bottom:5px">  
                        <f:facet name="start">  
                            <h:graphicImage library="icons" name="loading.gif" />  
                        </f:facet>  

                        <f:facet name="complete">  
                            <h:outputText value="" />  
                        </f:facet>  
                    </p:ajaxStatus> 
                    <p:dialog id="buyCreditsDialog" visible="#{(viewSearchBean.currentSearch.company.availableCredits - viewSearchBean.adquiredCandidates.size())lt(1)}" modal="true">
                        #{messages.CreditError}
                    </p:dialog>
                    <p:dialog resizable="false" id="candidateDetailDialog" widgetVar="candidateDetailDialog" modal="true">  
                            <p:panel rendered="#{viewSearchBean.selectedCandidate!=null}" id="sumaryInfoPanel" styleClass="viewDetailInfoPanel noMargin noPadding noBorder">
                                <h:outputText styleClass="titleText right block dialogHeader marginBottom20" value="#{viewSearchBean.selectedCandidate.name}"></h:outputText>
                                <p:panel styleClass="noMargin noPadding noBorder detailCandidatePanel">
                                    <div class="viewCandidateColumnTitle personalBackgroundButton">
                                        <span>#{messages.SearchGeneralInformation}</span>
                                    </div>
                                    <h:outputText class="viewCandidateLabel" rendered="#{viewSearchBean.selectedCandidate.name!=null}" value="#{viewSearchBean.selectedCandidate.name}"></h:outputText>
                                    <h:outputText class="viewCandidateText" rendered="#{viewSearchBean.selectedCandidate.birthDay!=null}" value="#{viewSearchBean.dateDifference(viewSearchBean.selectedCandidate.birthDay)} #{messages.Years}"></h:outputText>
                                    <h:outputFormat class="viewCandidateText marginBottom20" rendered="#{viewSearchBean.selectedCandidate.country!=null and viewSearchBean.selectedCandidate.province!=null}" value="#{messages.IndexLocationMessage}">
                                        <f:param value="#{viewSearchBean.selectedCandidate.province.description}"></f:param>
                                        <f:param value="#{viewSearchBean.selectedCandidate.country.description}"></f:param>
                                    </h:outputFormat>
                                    <div class="viewCandidateColumnTitle educationalBackgroundButton">
                                    <span>#{messages.Profile}</span>
                                    </div>
                                    <ui:repeat varStatus="professionalIteration" rendered="#{viewSearchBean.selectedCandidate.differentProfessionalTargetSectors!=null and !viewSearchBean.selectedCandidate.differentProfessionalTargetSectors.isEmpty()}" var="differentSector" value="#{viewSearchBean.selectedCandidate.differentProfessionalTargetSectors}">
                                        <h:outputText styleClass="bodyText" value="#{sectorBundle[differentSector.idSector.toString()]}"></h:outputText>
                                        <h:outputText rendered="#{!professionalIteration.last}" styleClass="bodyText" value=", "></h:outputText>
                                    </ui:repeat>
                                    <div class="marginBottom20"></div>
                                    <div class="viewCandidateColumnTitle languageBackgroundButton">
                                        <span>#{messages.Language}</span>
                                    </div>
                                    <ui:repeat varStatus="languageIteration" rendered="#{viewSearchBean.selectedCandidate.candidateLanguageInfoList!=null and !viewSearchBean.selectedCandidate.candidateLanguageInfoList.isEmpty()}" var="languageInfo" value="#{viewSearchBean.selectedCandidate.candidateLanguageInfoList}">
                                        <h:outputText styleClass="bodyText" value="#{languageBundle[languageInfo.language.idLanguage.toString()]} #{languageLevelBundle[languageInfo.languageLevel.idLanguageLevel.toString()]}"></h:outputText>
                                        <h:outputText rendered="#{!languageIteration.last}" styleClass="bodyText" value=", "></h:outputText>
                                    </ui:repeat>
                                </p:panel>
                                <h:graphicImage rendered="#{viewSearchBean.selectedCandidate.bodyFormal==null}" styleClass="imagenCuerpoDetalle floatRight" library="images" name="bustnotavailable.jpg"></h:graphicImage>                            
                                <h:graphicImage rendered="#{viewSearchBean.selectedCandidate.bodyFormal!=null}" styleClass="imagenCuerpoDetalle floatRight" value="/candidateFiles/#{viewSearchBean.selectedCandidate.idCandidate.toString()}/images/#{viewSearchBean.selectedCandidate.bustColor}"></h:graphicImage>
                            </p:panel>
                            <p:commandButton styleClass="cropButton interestBackgroundButton floatLeft" global="false" update=":facesForm:buyCreditsDialog :facesForm:adquiredFacesDataGrid :facesForm:recruitPanel :facesForm:recruitButton2" oncomplete="candidateDetailDialog.hide();" actionListener="#{viewSearchBean.reportSelectedCandidate}" value="#{messages.Report}"></p:commandButton>
                            <p:commandButton styleClass="cropButton imageBackgroundButton floatRight" global="false" update=":facesForm:buyCreditsDialog :facesForm:adquiredFacesDataGrid :facesForm:recruitPanel :facesForm:recruitButton2" oncomplete="candidateDetailDialog.hide();" actionListener="#{viewSearchBean.adquireSelectedCandidate}" value="#{messages.Select}"></p:commandButton>
                    </p:dialog>
                    
                    <p:dialog resizable="false" id="adquiredCandidateDetailDialog" widgetVar="adquiredCandidateDetailDialog" modal="true">  
                        <p:panel rendered="#{viewSearchBean.selectedAdquiredCandidate!=null}" id="sumaryAdquiredInfoPanel" styleClass="viewDetailInfoPanel noMargin noPadding noBorder">
                            <h:outputText styleClass="titleText right block dialogHeader marginBottom20" value="#{viewSearchBean.selectedAdquiredCandidate.name}"></h:outputText>
                            <p:panel styleClass="noMargin noPadding noBorder detailCandidatePanel">
                                <div class="viewCandidateColumnTitle personalBackgroundButton">
                                    <span>#{messages.SearchGeneralInformation}</span>
                                </div>
                                <h:outputText class="viewCandidateLabel" rendered="#{viewSearchBean.selectedAdquiredCandidate.name!=null}" value="#{viewSearchBean.selectedAdquiredCandidate.name}"></h:outputText>
                                <h:outputText class="viewCandidateText" rendered="#{viewSearchBean.selectedAdquiredCandidate.birthDay!=null}" value="#{viewSearchBean.dateDifference(viewSearchBean.selectedAdquiredCandidate.birthDay)} #{messages.Years}"></h:outputText>
                                <h:outputFormat class="viewCandidateText marginBottom20" rendered="#{viewSearchBean.selectedAdquiredCandidate.country!=null and viewSearchBean.selectedAdquiredCandidate.province!=null}" value="#{messages.IndexLocationMessage}">
                                    <f:param value="#{viewSearchBean.selectedAdquiredCandidate.province.description}"></f:param>
                                    <f:param value="#{viewSearchBean.selectedAdquiredCandidate.country.description}"></f:param>
                                </h:outputFormat>
                                <div class="viewCandidateColumnTitle educationalBackgroundButton">
                                    <span>#{messages.Profile}</span>
                                </div>
                                <ui:repeat rendered="#{viewSearchBean.selectedAdquiredCandidate.candidateProfessionalInfoList!=null and !viewSearchBean.selectedAdquiredCandidate.candidateProfessionalInfoList.isEmpty()}" var="professionalInfo" value="#{viewSearchBean.selectedAdquiredCandidate.candidateProfessionalInfoList}">
                                    <h:outputText styleClass="bodyText" value="#{professionalInfo.sector.description}, "></h:outputText>
                                </ui:repeat>
                                <div class="marginBottom20"></div>
                                <div class="viewCandidateColumnTitle languageBackgroundButton">
                                    <span>#{messages.Language}</span>
                                </div>
                                <ui:repeat rendered="#{viewSearchBean.selectedAdquiredCandidate.candidateLanguageInfoList!=null and !viewFolderBean.selectedAdquiredProfile.candidate.candidateLanguageInfoList.isEmpty()}" var="languageInfo" value="#{viewSearchBean.selectedAdquiredCandidate.candidateLanguageInfoList}">
                                    <h:outputText styleClass="bodyText" value="#{languageBundle[languageInfo.language.idLanguage.toString()]} #{languageLevelBundle[languageInfo.languageLevel.idLanguageLevel.toString()]}, "></h:outputText>
                                </ui:repeat>
                            </p:panel>
                            <h:graphicImage rendered="#{viewSearchBean.selectedAdquiredCandidate.bodyFormal==null}" styleClass="imagenCuerpoDetalle floatRight" library="images" name="bustnotavailable.png"></h:graphicImage>                            
                        </p:panel>
                        <p:commandButton styleClass="cropButton floatRight interestBackgroundButton" global="false" update=":facesForm:buyCreditsDialog :facesForm:adquiredFacesDataGrid :facesForm:recruitPanel :facesForm:recruitButton2" oncomplete="adquiredCandidateDetailDialog.hide();" actionListener="#{viewSearchBean.removeSelectedCandidate}" value="#{messages.Discard}"></p:commandButton>
                    </p:dialog>
                   
                    <p:panel styleClass="noMargin noPadding noBorder facesWrapPanel">
                       
                         <p:outputPanel id="update" styleClass="facesDataGrid noMargin noPadding noBorder">
                             <p:panel styleClass="noBorder noMargin noPadding" rendered="#{!viewSearchBean.interestedCandidates.isEmpty()}">
                                 <div class="viewCandidateColumnTitle personalBackgroundButton">
                                     <span>#{messages.InterestedCandidates}</span>
                                </div>
                             </p:panel>
                             <p:dataGrid emptyMessage="#{messages.NoInterestedCandidates}" styleClass="loadImages" id="interestedFacesDataGrid" var="candidate" value="#{viewSearchBean.interestedCandidates}" columns="#{4}" rowIndexVar="rowIndex"  rows="#{viewSearchBean.numberOfRows}" paginator="false" rendered="#{!viewSearchBean.interestedCandidates.isEmpty()}">
                                <p:column selectionMode="single" styleClass="facesColumn noPadding noMargin">
                                    <p:panel style="margin-left: 4px;" styleClass="inlineBlock noPadding noBorder facesPanel rotation polaroidBackground rotate#{polaroidBean.randomRotation}">  
                                        <h:panelGrid columns="1" columnClasses="facesColumn" styleClass="noMargin noPadding noBorder facesPanel">  
                                            <p:commandLink styleClass="imagenBusqueda" actionListener="#{viewSearchBean.selectFace(candidate)}" process="@this" global="true" oncomplete="candidateDetailDialog.show();"  update=":facesForm:candidateDetailDialog :facesForm:sumaryInfoPanel">  
                                                <!--<h:graphicImage styleClass="imagenBusqueda" library="images" name="bustnotavailable.png"></h:graphicImage>!-->                        
                                                <h:graphicImage style="min-height: 135px" rendered="#{candidate.bustColor!=null and adquiredCandidatesBean.isAdquired(candidate)}" styleClass="imagenBusqueda" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustColor}"></h:graphicImage>                 
                                                <h:graphicImage style="min-height: 135px" rendered="#{candidate.bustBlackWhite!=null and !adquiredCandidatesBean.isAdquired(candidate)}" styleClass="imagenBusqueda" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustBlackWhite}"></h:graphicImage>                 
                                                <f:setPropertyActionListener value="#{candidate}" target="#{viewSearchBean.selectedCandidate}" />  
                                            </p:commandLink> 
                                            <h:outputText styleClass="polaroidText" value="#{candidate.name}, #{candidate.yearsOld}"></h:outputText>
                                        </h:panelGrid>  
                                    </p:panel> 
                                </p:column>
                            </p:dataGrid>
                              <p:panel styleClass="noBorder marginTop20 noPadding">
                                 <div class="viewCandidateColumnTitle interestBackgroundButton">
                                     <span>#{messages.AllValidCandidates}</span>
                                </div>
                             </p:panel>
                            <p:dataGrid emptyMessage="#{messages.NoValidCandidates}" styleClass="loadImages" id="facesDataGrid" var="candidate" value="#{viewSearchBean.candidates}" columns="#{4}" rowIndexVar="rowIndex"  rows="#{viewSearchBean.numberOfRows}" paginator="false" >
                                <p:column selectionMode="single" styleClass="facesColumn noPadding noMargin">
                                    <p:panel style="margin-left: 4px;" styleClass="inlineBlock noPadding noBorder facesPanel rotation polaroidBackground rotate#{polaroidBean.randomRotation}">  
                                        <h:panelGrid columns="1" columnClasses="facesColumn" styleClass="noMargin noPadding noBorder facesPanel">  
                                            <p:commandLink styleClass="imagenBusqueda" actionListener="#{viewSearchBean.selectFace(candidate)}" process="@this" global="true" oncomplete="candidateDetailDialog.show();"  update=":facesForm:candidateDetailDialog :facesForm:sumaryInfoPanel">  
                                                <!--<h:graphicImage styleClass="imagenBusqueda" library="images" name="bustnotavailable.png"></h:graphicImage>!-->                        
                                                <h:graphicImage style="min-height: 135px" rendered="#{candidate.bustColor!=null and adquiredCandidatesBean.isAdquired(candidate)}" styleClass="imagenBusqueda" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustColor}"></h:graphicImage>                 
                                                <h:graphicImage style="min-height: 135px" rendered="#{candidate.bustBlackWhite!=null and !adquiredCandidatesBean.isAdquired(candidate)}" styleClass="imagenBusqueda" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustBlackWhite}"></h:graphicImage>                 
                                                <f:setPropertyActionListener value="#{candidate}" target="#{viewSearchBean.selectedCandidate}" />  
                                            </p:commandLink> 
                                            <h:outputText styleClass="polaroidText" value="#{candidate.name}, #{candidate.yearsOld}"></h:outputText>
                                        </h:panelGrid>  
                                    </p:panel> 
                                </p:column>
                            </p:dataGrid>
                            
                            <p:panel id="linkOutputPanel" styleClass="waypointPanel"  rendered="#{viewSearchBean.candidates.size() lt viewSearchBean.maxCandidates}" style="width:100%;margin-bottom: 50px;vertical-align: top;text-align: center; background-color: #e1ad0f;margin-left: 10px;">
                                <p:commandLink update="update" global="true" id="moreCandidatesLink" style="margin-bottom: 50px; width:100%;" value="#{messages.More}" actionListener="#{viewSearchBean.searchMoreCandidates()}"></p:commandLink>
                            </p:panel>
                            
                        </p:outputPanel>
                        
                        <p:panel styleClass="adquiredFacesPanelWrap">
                            <p:panel id="adquiredFacesPanel" styleClass="adquiredFacesPanel adquiredFacesDataGrid noBorder">
                                <div class="viewCandidateColumnTitle professionalBackgroundButton">
                                    <span>#{messages.SelectedCandidates}</span>
                                </div>
                                <div style="overflow:scroll;max-height:400px;">
                                <p:dataGrid emptyMessage="" id="adquiredFacesDataGrid" styleClass="adquiredFacesDataGrid" var="adquiredCandidate" value="#{viewSearchBean.adquiredCandidates}" columns="2" rows="#{viewSearchBean.adquiredCandidates.size()}" paginator="false" >
                                    <p:column>
                                        <p:panel styleClass="noMargin noBorder noPadding">  
                                            <p:commandLink global="false" oncomplete="adquiredCandidateDetailDialog.show();" update=":facesForm:sumaryAdquiredInfoPanel :facesForm:adquiredCandidateDetailDialog">  
                                                <h:graphicImage rendered="#{adquiredCandidate.bustColor==null}" styleClass="adquiredImage" library="images" name="bustnotavailable.jpg"></h:graphicImage>                            
                                                <h:graphicImage rendered="#{adquiredCandidate.bustColor!=null}" styleClass="adquiredImage" value="/candidateFiles/#{adquiredCandidate.idCandidate.toString()}/images/#{adquiredCandidate.bustColor}"></h:graphicImage>                            
                                                <f:setPropertyActionListener value="#{adquiredCandidate}" target="#{viewSearchBean.selectedAdquiredCandidate}" />  
                                            </p:commandLink>  
                                        </p:panel> 
                                    </p:column>
                                </p:dataGrid>
                                </div>
                                <p:commandButton id="recruitButton2" disabled="#{viewSearchBean.adquiredCandidates.isEmpty()}" styleClass="updatePicturesButton orangeBG " action="#{viewSearchBean.recruit()}" value="#{messages.Recruit}"></p:commandButton>
                            </p:panel>
                        </p:panel> 
                        <p:panel id="recruitPanel" styleClass="noMargin noPadding noBorder">
                            <p:commandButton id="recruitButton" disabled="#{viewSearchBean.adquiredCandidates.isEmpty()}" styleClass="updatePicturesButton orangeBG " action="#{viewSearchBean.recruit()}" value="#{messages.Recruit}"></p:commandButton>
                        </p:panel>
                    </p:panel>
                    <p:panel styleClass="noBorder">
                        <p:remoteCommand global="true" id="loadMoreCandidates" name="loadMoreCandidates" process="@this" update="@parent update waypoint"  
                                         actionListener="#{viewSearchBean.searchMoreCandidates}"  
                                         oncomplete="handleLoadStop(#{viewSearchBean.candidates.size()},#{viewSearchBean.numberOfCandidatesPerView},#{viewSearchBean.maxCandidates})"/>  
                    </p:panel>
                    <p:panel id="footer" styleClass="noBorder">
                        <pe:waypoint rendered="#{viewSearchBean.count lt viewSearchBean.maxCandidates}" id="waypoint" widgetVar="waypointWidget"  
                                     offset="function(){return $.waypoints('viewportHeight') - $(this).outerHeight()+15}">
                            <pe:javascript event="reached" execute="handleLoadStart(ext);"/>
                        </pe:waypoint>
                    </p:panel>  
                </h:form>
            </ui:define>
        </ui:composition>

    </body>
</html>
